<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="test">
        <!--计数器功能区域-->
        <div class="input-num">
            <button v-on:click="sub">
                -
            </button>
            <span>{{ num }}</span>
            <button v-on:click="add">
                +
            </button>
        </div>
    </div>
</body>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
    var test = new Vue({
        el:"#test",
        data:{
            num:1
        },
        methods:{
            add:function(){
                if(this.num < 10){
                    this.num++;
                }else{
                    alert("不能再加了！");
                }
            },
            sub:function(){
                if(this.num > 0){
                    this.num--;
                }else{
                    alert("不能再减了！");
                }
            }
        }
    })
</script>
</html>